package com.cyh.testdesignpattern.state;

import android.util.Log;

//发放奖品的状态
public class DispenseState extends State {
    //初始化时传入活动引用，发放奖品后改变其状态
    RaffleAction action;

    public DispenseState(RaffleAction action) {
        this.action = action;
    }

    //当前状态不可以扣除积分
    @Override
    public void deductMoney() {
        Log.i("DispenseState", "正在发放奖品，不能扣除积分！");
    }

    //当前状态不能抽奖
    @Override
    public boolean raffle() {
        Log.i("DispenseState", "正在发放奖品，不能抽奖！");
        return false;
    }

    //当前状态不能发放奖品
    @Override
    public void dispensePrize() {
        Log.i("DispenseState", "正在发放奖品。。。。");
        if(action.getCount() > 0) {
            Log.i("DispenseState", "恭喜中奖了！");
            action.setState(action.getNoRaffleState());
        } else {
            Log.i("DispenseState", "很遗憾、奖品发送完了");
            action.setState(action.getDispenseOutState());
        }
    }
}
